package com.seaboxdata.interfaceJob;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

@Component
@Configuration
@Slf4j
public class GpsMessageCleanJob {
   /* @Value("${connector.daxin.vehicle.gps.deleteLatency}")
    private Integer deleteLatnecy;
    @Value("${connector.daxin.vehicle.gps.deleteStandard}")
    private String deleteStandard;

    @Autowired
    private GpsMessageService gpsMessageService;
    private DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
    @Scheduled(cron = "${crontab.gpscleaninterval}")
    private void doGpsClean(){
        LocalDateTime dateTime=LocalDateTime.now();
        //计算上限时间
        if(deleteStandard.equalsIgnoreCase("H")) {
            dateTime = dateTime.minusHours(deleteLatnecy);
        }else if(deleteStandard.equalsIgnoreCase("D")){
            dateTime=dateTime.minusDays(deleteLatnecy);
        }
        int count;
        if((count=gpsMessageService.deleteByMaxRowId(dateTime.format(df)))>0){
            log.info("--delete timely at {} with rows {}",dateTime.format(df),count);
        }else{
            log.info("--delete timely with no record ---");
        }
    }*/
}
